﻿using Pattern04抽象工厂模式.Factories;
using Pattern04抽象工厂模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pattern04抽象工厂模式
{
    public class Client
    {
        public void Start()
        {
            IFactory appleFactory = new AppleFactory();
            DoStuff(appleFactory);

            IFactory samsungFactory = new SamsungFactory();
            DoStuff(samsungFactory);
        }

        private void DoStuff(IFactory factory)
        {
            Console.WriteLine($"{factory.GetType().Name} 开始生产");
            var phone = factory.GetPhone();
            phone.Produce(99, 90);
            phone.Write();

            var tv = factory.GetTV();
            tv.Produce(88, 90);
            tv.Print();
            Console.WriteLine($"{factory.GetType().Name} 生产结束");

        }

    }
}
